<template>
<div class="adticket-list">
<div class="adticket-list-top">你好！尊贵的VIP会员：{{adminUserName}}</div>
<table class="adticket-list-table">
	<tr>
		<th>序号</th>
		<th>出发地</th>
		<th>到达地</th>
		<th>出发时间</th>
		<th>车票类型</th>
		<th>持票人</th>
		<th>操作</th>
	</tr>
	<tr v-for="d in datas">
		<td>{{d.id}}</td>
		<td>{{d.start}}</td>
		<td>{{d.end}}</td>
		<td>{{d.startTime}}</td>
		<td>{{d.ticketType}}</td>
		<td>{{d.adminUserName}}</td>
		<td>
			<input type="button" value="退订"  @click="deleteAdticket(d.id)" style="width:110px; height:40px;">
		</td>
	</tr>
</table>
<div class="adticket-bottom">
		1.如果查询结果中没有满足需求的车次，您还可以使用接续换乘 功能，查询途中换乘一次的部分列车余票情况。<br>
		2.显示的卧铺票价均为上铺票价，供您参考。具体票价以您确认支付时实际购买的铺别票价为准。
</div>
</div>
</template>
 
<script>
module.exports = {
    data: function() {
        return {
        	adminUserName : '',
        	datas : ''
        }
    },
    mounted : function(){
    	var target = this;
    	this.seeklogin(function(){
		    target.adticket();
    	});
    },
    methods : {
    	//判断用户是否登录
    	seeklogin : function(callback){
    		var target = this;
    		axios.get('/common/seeklogin')
			.then(function (response){
				var success = response.data.success;
				if(success!=false){
					target.adminUserName = response.data.result.data;
					
				}else{
					alert("你还没登录！");
					window.location.href = "./Login.html";
				}
				//用于回调
				if(callback){
					callback();
				}
			})
			.catch(function (error) {
				console.log(error);
			});
    	},
    	//查找当前登录用户所购买的车票信息
    	adticket : function(){
    		var target = this;
    		axios.post('/bac/adticket/selectAdticket',{
    			adminUserName : this.adminUserName
    		})
    		.then(function(response){
    			if(response.data.success == false){
    				alert("未登录无法查询车票信息！");
    			}else{
    				target.datas = response.data.result.data;
    			}
    		})
    		.catch(function(error){
    			console.log(error);
    		});
    	},
    	//删除退订的车票
    	deleteAdticket : function(id){
    		var target = this;
    		axios.post('/bac/adticket/deleteAdticket',{
    			id : id
    		})
    		.then(function(response){
    			if(response.data.success == true){
    				alert("退订成功");
    				window.location.reload();
    			}
    		})
    		.catch(function(error){
    			console.log(error);
    		});
    	}
    }
}
</script>
 
<style>
	body,ul,li,a{
		padding:0px;
		margin:0px;
		text-decoration:none;
		list-style:none;
	}
	.adticket-list{
		width:auto;
		min-height:800px;
		height:auto;
		margin:0px 120px;
		margin-bottom:20px;
		padding-top:10px;
		padding-bottom:10px;
	}
	.adticket-list-table{
		background-color:#F5DEB3;
		margin:10px 220px;
		text-align:center;
		border: double 1px #EAEAEA;
	}
	.adticket-list-table tr th{
		border: double 1px #EAEAEA;	
		width:150px;
		height:80px;
		background-color:#1E90FF;
	}
	.adticket-list tr td{
		border: double 1px #EAEAEA;
		width:150px;
		height:50px;
	}
	.adticket-list-top{
		margin:0px 0px 0px 220px; 
		background-color:#D2691E; 
		width:1095px;
		height:35px;
		font-size:22px;
		text-align:center;
		padding-top:10px;
	}
	.adticket-bottom{
		font-size:15px;
		margin:0px 220px;
		width:1073px;
		border:2px double #696969;
		background-color:#F0E68C;
		padding:10px;
	}
</style>